﻿using System;
using System.Web.Mvc;
using ATTools.Models;
using Orchard.ContentManagement;
using Orchard.Environment.Extensions;
using Orchard.Mvc.Filters;
using Orchard.Settings;
using Orchard.UI.Resources;

namespace ATTools.Filters
{
    [OrchardFeature("ATTools.VoiceCommands")]
    public class ScriptFilter : FilterProvider, IResultFilter
    {
        private readonly IResourceManager _resourceManager;

        public ScriptFilter(IResourceManager resourceManager)
        {
            _resourceManager = resourceManager;
        }

        public void OnResultExecuted(ResultExecutedContext filterContext)
        {
        }

        public void OnResultExecuting(ResultExecutingContext filterContext)
        {
            //Include speech on inputs JavaScript.
            _resourceManager.Require("script", "SpeechOnAllInput");
        }
    }
}